package org.jeecg.modules.knowledgeType.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.columnmanager.vo.ColumnManagerVO;
import org.jeecg.modules.knowledgeType.mapper.KnowledgeColumnMapper;
import org.jeecg.modules.knowledgeType.service.IKnowledgeColumnService;
import org.jeecg.modules.knowledgeType.vo.KnowledgeColumnVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 评论
 * @Author: jeecg-boot
 * @Date:   2020-11-12
 * @Version: V1.0
 */
@Service
public class KnowledgeColumnServiceImpl extends ServiceImpl<KnowledgeColumnMapper, KnowledgeColumnVO> implements IKnowledgeColumnService {
    @Autowired
    private KnowledgeColumnMapper knowledgeColumnMapper;
    @Autowired
    private RedisUtil redisUtil;
    @Override
    public IPage<ColumnManagerVO> myPage(Page<ColumnManagerVO> page) {
        List<ColumnManagerVO> columnInfo =  knowledgeColumnMapper.myPage(page);
            columnInfo.forEach(info->{
                info.setColumnImageString(info.getcolumnImageString());
            });
        return page.setRecords(columnInfo);
    }

    @Override
    public void myDelete(String id) {
        knowledgeColumnMapper.myDelete(id);
//        redisUtil.del(RedisConstant.ALL_COLUMN_INFO);
    }

    @Override
    public String getIdByName(String name) {

        return knowledgeColumnMapper.getIdByName(name);
    }


    @Override
    public List<ColumnManagerVO> queryAllColumn() {
        List<ColumnManagerVO> columnInfo = knowledgeColumnMapper.myPage(new Page<ColumnManagerVO>());
        return columnInfo;
    }

    @Override
    public List<ColumnManagerVO> queryNotPage() {
        return knowledgeColumnMapper.queryNotPage();
    }

}
